package com.tank;

import java.awt.*;

/**
 * 爆炸
 * @author CaoBaoYin
 * @since 2021/8/18 22:21
 */
public class Explode {
    public static final int WIDTH = ResourceManager.explodes[0].getWidth();
    public static final int HEIGHT = ResourceManager.explodes[0].getHeight();

    private int x, y;

    private boolean live = true;//判断字段是否存活

    private TankFrame tf;

    public Explode(int x, int y, TankFrame tf) {
        this.x = x;
        this.y = y;
        this.tf = tf;

        new Thread(()->new Audio("audio/explode.wav").play()).start();
    }

    private int step = 0;
    public void paint (Graphics g) {
        g.drawImage(ResourceManager.explodes[step++], this.x, this.y, null);

        if (step >= ResourceManager.explodes.length) {
            this.tf.explodeList.remove(this);
        }
    }
}
